package itsm.isperp.module.controller.project;

import itsm.isperp.framework.web.controller.BaseController;
import itsm.isperp.framework.web.request.JqGridFilterRule;
import itsm.isperp.framework.web.request.JqGridFilterRuleOp;
import itsm.isperp.framework.web.request.JqGridRequest;
import itsm.isperp.module.entity.project.ProjCostItem;
import itsm.isperp.module.service.project.ProjCostItemService;
import itsm.isperp.module.service.project.ProjProjectService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 项目预算管理控制器
 * 
 * @author lizx
 * @date 2013-2-26
 * @version V1.0
 */
@Controller
@RequestMapping("project/costItem")
public class ProjCostItemController extends BaseController<ProjCostItem> {

	@Autowired
	protected ProjProjectService projProjectService;

	@Autowired
	protected ProjCostItemService projProjectCostItemService;

	@Override
	public ProjCostItemService getService() {
		return this.projProjectCostItemService;
	}

	@Override
	public String getPageTitle() {
		return "项目人员管理";
	}

	@RequestMapping("projectCostItemList")
	@ResponseBody
	public Page<ProjCostItem> projectCostItemList(String projectId,
			JqGridRequest request) {
		if (StringUtils.isNotEmpty(projectId)) {
			// 增加项目id字段过滤规则
			request.addFilterRule(new JqGridFilterRule("proj_project_id",
					JqGridFilterRuleOp.eq, projectId));
		}
		return this.projProjectCostItemService.findAll(request);
	}

}
